<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateSeecmsUserLoginTable extends Migration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */

    protected $name = 'seecms_user_login';

    public function up()
    {
        Schema::create($this->name, function (Blueprint $table) {
            $table->id();
            $table->integer('user_id')->comment('用户id');
            $table->string('ip')->comment('登录ip')->default('');
            $table->string('browser')->comment('浏览器')->default('');
            $table->string('browser_version')->comment('浏览器版本')->default('');
            $table->string('device')->comment('设备')->default('');
            $table->string('platform')->comment('平台')->default('');
            $table->string('platform_version')->comment('平台版本')->default('');
            $table->string('is_mobile')->comment('是否移动端 0 不是 no 1 是 yes')->default(0);
            $table->string('status')->comment('登录结果 0 失败 fail 1 成功 success')->default(1);
            $table->string('reason')->comment('登录失败原因')->default('');
            $table->string('user_agent')->comment('登录标识')->default('');
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists($this->name);
    }
}
